//屏蔽
sType = getUrlParam("type"); //sType  1暂定裸钻，2 统包 3成品
var stockList=[];//现货
var filter={};
(function(){
	filter={
		init:function(){
			this.bindEvents();
			// LoadSupplier();
            getSupplierIsStockList();
            localStorage.removeItem('click_index');
		},
		bindEvents:function(){
			var self=this;
			//状态切换搜索1
	        var url = window.location.href;
		    $('#categories li a').each(function () {
		        if (returnUrl($(this).attr('href'))== returnUrl(url)){
		            $(this).parents("li").addClass('cur');
		        }
		    });
            $(".se_nav a:eq(" + (sType - 1) + ")").attr("class", "active");

            //点击全选
            $("#checkbox_check_all").on("click",function(){
                $(this).toggleClass("selected");
                if($(this).hasClass("selected")){
                    $("#stock_body .check_list_box").children("span").addClass("selected");
                    $("#stock_body .check_list_box").closest("tr").addClass('tr_select_color');//全选tr加背景色
                    $("#stock_btn").css("background-color", primary_color);//按钮样式
                    $("#stock_btn").attr("disabled", false);
                }else{
                    $(".check_list_box").children("span").removeClass("selected");
                    $("#stock_body .check_list_box").closest("tr").removeClass('tr_select_color');
                    self.clearBtn();
                }
            });
            //列表的勾选框--按序号选中
            $("#stock_body").on("click",".check_rel",function(){
                $(this).find('.check_list_box').children("span").toggleClass("selected");
                if($(this).find('.check_list_box').children("span").hasClass("selected")){
                    $(this).closest("tr").addClass('tr_select_color');
                }else{
                    $(this).closest("tr").removeClass('tr_select_color');
                }
                //判断是否全选，全选选中
                var length=$("#stock_body .check_list_box span").length;
                var checkLength=$("#stock_body .check_list_box span.selected").length;
                if(checkLength>0){//给按钮批量删除添加颜色
                    $("#stock_btn").css("background-color", primary_color);
                    $("#stock_btn").attr("disabled", false);
                }else{//去掉按钮批量删除的颜色
                    self.clearBtn();
                }
                if(length==checkLength){//全选按钮选中
                    $("#checkbox_check_all").addClass("selected");
                }else{
                    $("#checkbox_check_all").removeClass("selected");
                }
            });

            //设置现货start
            $("#stock_btn").on("click",function(){
                myApp.popup("#stock_box");
            });

            $("#form_stock_choose span").on("click",function(){
                $(this).addClass("active").siblings().removeClass("active");
            });

            $("#stock_form_btn").on("click",function(){
                self.diamondStock();
            });
            //设置现货end



            //输入搜索
//          $("#search").keyup(function () {//输入框
//              self.SearchSupplier();
//          });
            //点击搜索
            $("#search_btn_box input[type=button]").on("click",function(){//点按钮搜索
            	var val=$(this).attr("data-value");
                localStorage.setItem('click_index',val);
                if(val=='-1'){
                localStorage.removeItem('click_index');
            }
            	self.SearchSupplier(val);
            });
		    //详情框禁用
			$(".edit_form .form-group :input").attr("readonly","readonly");
		    //排序
            $("#product_table_fixed").on("click","thead .up_down",function(){
            	if($(this).hasClass("sort_up")){
            		$(this).siblings(".up_down").removeClass("sort_up")&&$(this).siblings(".up_down").removeClass("sort_down");
            		$(this).addClass("sort_down").removeClass("sort_up");
            	}else if($(this).hasClass("sort_down")){
            		$(this).siblings(".up_down").removeClass("sort_down")&&$(this).siblings(".up_down").removeClass("sort_up");
            		$(this).addClass("sort_up").removeClass("sort_down");
            	}else{
            		$(this).siblings(".sort_up").removeClass("sort_down")&&$(this).siblings(".up_down").removeClass("sort_up");
            		$(this).addClass("sort_down");
            	}
            	var dataNum=$(this).attr("data-num");//
            	numSort($(this),dataNum);//排序的方法
            });
		},
        //清除按钮颜色
        clearBtn:function(){
            $(".search_btn_b").css("background-color","#a1a1a1");
            $(".search_btn_b").attr("disabled",true);
        },

        //设置现货
        diamondStock:function(){
            var supplierlistCb = $("#stock_body .check_rel span.selected");//checked的

            var _type=$("#form_stock_choose span.active").attr("data-type");//1为上架，0为下架
            var _supplierIDs = [];//批量修改的id的集合
            for (var i = 0; i < supplierlistCb.length; i++) {
                _supplierIDs.push(supplierlistCb[i].lang);
            }
            var submitJson={};
            submitJson.SupplierCode=_supplierIDs;

            submitJson.SupplierType=sType;
            submitJson.is_stock=_type;

            $.ajax({
                url:"/team/UpdateSupplierIsStock",
                type:"POST",
                data:JSON.stringify(submitJson),
                contentType: "application/json; charset=utf-8",
                success: function (result) {//返回修改成功的信息
                    var res=JSON.parse(result);
                    if(res.msgcode==true){
                        myApp.alert(res.msginfo);//--显示批量修改供应商角色成功提示框
                        $("#stock_box").hide();
                        getSupplierIsStockList();
                    }else{
                        myApp.alert(_(res.msginfo));
                    }
                }
            });
        },
		//搜索
		SearchSupplier:function(c) {
            var searchtext;
            if (c == 0 || c == 1) {  //开关
                searchtext = "Filter" + c;
            }
            else if(c==-1){
                searchtext = $("#search").val();
            }
            if (searchtext == "") {
                $("#product_table tbody tr").show();
            }
            else {
                $("#product_table tbody tr").hide();
                $("#product_table tbody tr:contains(" + searchtext + ")").show();
                
            }
        }
	}
	filter.init();
})();
//排序
var arr = [{name: "zlw", age: "24"},{name: "alz", age: "5"}, {name: "wlz", age: "5"}];
var compare_x = function (prop) {//从小到大排序
    return function (obj1, obj2) {
        var val1 = obj1[prop];
        var val2 = obj2[prop];
        if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
            val1 = Number(val1);
            val2 = Number(val2);
        }
        if (val1 < val2) {
            return -1;
        } else if (val1 > val2) {
            return 1;
        } else {
            return 0;
        }            
    } 
};
var compare_d = function (prop) {//从大到小排序
    return function (obj1, obj2) {
        var val1 = obj1[prop];
        var val2 = obj2[prop];
        if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
            val1 = Number(val1);
            val2 = Number(val2);
        }
        if (val1 > val2) {
            return -1;
        } else if (val1 < val2) {
            return 1;
        } else {
            return 0;
        }            
    } 
};
//排序Start
var sortData=[];//加载到的result数据
function numSort(that,num){
	//账号
	if(num==0 && that.hasClass("sort_down")){
		changeSort("supplier",compare_x);
			
	}else if(num==0 && that.hasClass("sort_up")){
		changeSort("supplier",compare_d);
	}
	//简称
	if(num==1 && that.hasClass("sort_down")){
		changeSort("short_name",compare_x);
	}else if(num==1 && that.hasClass("sort_up")){
		changeSort("short_name",compare_d);
	}
	//全称
	if(num==2 && that.hasClass("sort_down")){
		changeSort("full_name",compare_x);
	}else if(num==2 && that.hasClass("sort_up")){
		changeSort("full_name",compare_d);
	}
	//开关
	if(num==3 && that.hasClass("sort_down")){
		for(var i=0;i<sortData[0].rows.length;i++){
			if(sType==1){
				sortData[0].rows[i].state=sortData[0].rows[i].whitelist.stocks;//裸钻
			}else if(sType==2){//parcel
				sortData[0].rows[i].state=sortData[0].rows[i].whitelist.parcels;//统包
			}else if(sType==3){//inlays
				sortData[0].rows[i].state=sortData[0].rows[i].whitelist.inlays;//成品
			}
		}
		changeSort("state",compare_d);
	}else if(num==3 && that.hasClass("sort_up")){
		for(var i=0;i<sortData[0].rows.length;i++){
			if(sType==1){
				sortData[0].rows[i].state=sortData[0].rows[i].whitelist.stocks;//裸钻
			}else if(sType==2){//parcel
				sortData[0].rows[i].state=sortData[0].rows[i].whitelist.parcels;//统包
			}else if(sType==3){//inlays
				sortData[0].rows[i].state=sortData[0].rows[i].whitelist.inlays;//成品
			}
		}
		changeSort("state",compare_x);
	}

    //现货
    if(num==4 && that.hasClass("sort_down")){
        changeSort("full_name",compare_x);
    }else if(num==4 && that.hasClass("sort_up")){
        changeSort("full_name",compare_d);
    }
};
function changeSort(numData,method){//由大到小排序
	var num2=sortData[0].rows.sort(method(numData));
		sortData[0].rows=num2;
		BindingData(sortData[0], $("#product_table tbody"));
};
//-排序end

//加载数据
function LoadSupplier(){
	var self=this;
	myApp.showIndicator();//显示加载中
    var requestSupplier={};
    requestSupplier.GoodsType=sType;
    $.ajax({
        url: "/Team/GetCenterSuppliers",//提交地址
        type: "POST",//提交方式
        data: JSON.stringify(requestSupplier),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
        	var result = eval('(' + result + ')');//eval()解析单个json对象
        	myApp.hideIndicator();//隐藏加载中	
            BindingData(result, $("#product_table tbody"));//绑定数据
            sortData.push(result);//排序--用的数据
            //排序
            //var ex1 = new tableSort('product_table', 1,1,2,999, 'sort_up', 'sort_down', 'hov');
        }
    });
};

//获取现货
function getSupplierIsStockList(){
    var submitJson={};
    submitJson.SupplierType=sType;//产品类型1裸钻，2统包
    var promise=$.ajax({
        type:"POST",
        url:"/team/GetSupplierIsStockList",
        data:JSON.stringify(submitJson),
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var res=JSON.parse(result);
            if(res.msgcode==true){
                stockList=res.msginfo;
            }
        }
    });
    promise.then(LoadSupplier);

}

//绑定数据
function BindingData(Datas, tableTbody){
	var self=this;
//	var _result = eval('(' + Datas + ')');//eval()解析单个json对象
	var _result =Datas;
    if (_result.msgcode == false) {
        var tr = "";//单行
        var tds = "<td colspan='50' style='text-align:center;color:red'>" + _(_result.msginfo) + "</td>";// 多列合成一列并居中
        tr = "<tr>" + tds + "</tr>";//将多列加到一行
        tableTbody.html(tr);//加入到id为customer的table的tbody中
    } else {
	    	_result = _result.rows;//object
		if(_result.length==0){
			var tablehtml = "<tr><td colspan='10'>" + _("没有数据") + "</td></tr>";//单行
			tableTbody.html(tablehtml);
		}else{
			
	        var trs = "";//多行数据
	        // var _index = 0;
	        for (var i = 0; i < _result.length; i++) {
	            var tds = "";//多列
	            var tr = "";//单行
	            //检测是否有这个供应商
	            if (sType === "1" && _result[i].classify.stocks == true || sType === "3" && _result[i].classify.inlays == true || sType === "2" && _result[i].classify.parcels == true || sType === "4" && _result[i].classify.gems == true || sType === "5" && _result[i].classify.emeralds == true || sType === "6" && _result[i].classify.prime_golds == true || sType === "7" && _result[i].classify.inlay_settings == true) {
	                // _index++;
	                // tds += "<td>" + _index + "</td>";
                    tds += "<td class='check_rel' style='width: 6%'>"+
                        "<div class='check_list_box'><span class='checkbox' name='checkbox' lang='" + _result[i].supplier + "'></span></div>";//1供应商ID
	                //tds += "<td><input type='checkbox' lang='" + _result[i].SupplierID + "'/></td>";
	                tds += "<td class='num1' onclick='Detail_box(this)' data-supplier='" + _result[i].supplier + "'>" + _result[i].supplier +
					"</td>";
	                tds += "<td onclick='Detail_box(this)' data-supplier='" + _result[i].supplier + "'>" + _result[i].short_name + "</td>";
	                tds += "<td onclick='Detail_box(this)' data-supplier='" + _result[i].supplier + "'>" + _result[i].full_name + "</td>";
                    tds +="<td>"+getSupplierStock(_result[i].supplier)+"</td>";//是否现货
	                if (sType === "1" && _result[i].whitelist.stocks === true || sType === "3" && _result[i].whitelist.inlays === true || sType === "2" && _result[i].whitelist.parcels === true || sType === "7" && _result[i].whitelist.inlay_settings === true) {
	                    tds += "<td class='check_toolbtn'><span style=display:none>Filter0</span>"+
	                    "<span class='filer_modify' data-shortname='" + _result[i].short_name + "' lang='" + _result[i].full_name + "' title='"+_("点击屏蔽")+"\"" + _result[i].supplier + "\""+_("供应商")+"' onclick='Filter(this," + sType + ",0)' value='" + _result[i].supplier + "'>"+_("关")+"</span>" +
	                        "<span class='filer_modify isopen' style='color:#fff;'  lang='" + _result[i].full_name + "' title='"+_("点击放开")+"\"" + _result[i].supplier + "\""+_("供应商")+"'  data-shortname='" + _result[i].short_name + "' onclick='Filter(this," + sType + ",0)' value='" + _result[i].supplier + "'>"+_("开")+"</span>" +
	                           "</td>";
	                } else {
	                    tds += "<td class='check_toolbtn'><span style=display:none>Filter1</span>"+
	                    "<span class='filer_modify isclose' lang='" + _result[i].full_name + "' data-shortname='" + _result[i].short_name + "' style='color:#fff;' title='"+_("点击屏蔽")+"\"" + _result[i].supplier + "\""+_("供应商")+"' onclick='Filter(this," + sType + ",1)' value='" + _result[i].supplier + "'>"+_("关")+"</span>" +
	                    "<span class='filer_modify' lang='" + _result[i].full_name + "' data-shortname='" + _result[i].short_name + "' title='"+_("点击放开")+"\"" + _result[i].supplier + "\""+_("供应商")+"' onclick='Filter(this," + sType + ",1)' value='" + _result[i].supplier + "'>"+_("开")+"</span></td>";
	                }
	                tr += "<tr>" + tds + "</tr>";//将多列加到一行
	            }
	            trs += tr;//将单行加到多行
	        }
	
	        tableTbody.html(trs);//加入到id为product_table的table的tbody中  tableTbody is $("#product_table")
			$(".isclose").css({"background-color":"#f60"});//--
	    	$(".isopen").css({"background-color":primary_color});
            if(localStorage.getItem('click_index')=='0'||localStorage.getItem('click_index')=='1'){
                var val=localStorage.getItem('click_index');
                filter.SearchSupplier(val)
            }
//	    	$(".filer_modify").hover(function(){
//	    		$(this).addClass("_filer_modify");
//	    	},function(){
//	    		$(this).removeClass("_filer_modify");
//	    	});
	    }
    }
};
//点击查看详情

//匹配供应商角色
function getSupplierStock(sup){
    var supplierArrays=stockList;
    var roleName="-";
    //匹配好供应商之后，返回对应的角色名
    for(var i=0;i<supplierArrays.length;i++){
        if(supplierArrays[i].SupplierCode==sup){
            roleName='是';
            break;
        }
    }
    return roleName;
}

//供应商详情
function Detail_box(me) {
	myApp.popup(".supplier_form_box");//弹框出现
    var s_name = $(me).attr("data-supplier");
    supplierDetails(s_name);
}
//供应商详情数据接口
function supplierDetails(s_name) {
    var data = {};
    data.supplierCode = s_name;
    var dataJson = JSON.stringify(data);
    $.ajax({
        url: "/Team/GetCenterSupplier",//提交地址
        type: "POST",//提交方式
        data: dataJson,
        contentType: "application/json; charset=utf-8",
        success: function (result) {
            var _result = eval('(' + result + ')');
            if (_result.msgcode == true) {
                $("#detail_box").show();
                var data = _result.msginfo;
                $(".detail_SupplierCompany").val(data.Company);
                $(".detail_SupplierWebsite").val(data.Contact.Website);
                $(".detail_SupplierQQ").val(data.Contact.QQ);
                $(".detail_SupplierRapID").val(data.Contact.RapID);
                $(".detail_SupplierName").val(data.Contact.Name);
                $(".detail_SupplierComment").val(data.Contact.Comment);
                $(".detail_SupplierTelephone").val(data.Contact.Telephone);
                $(".detail_SupplierTelephone1").val(data.Contact.Telephone1);
                $(".detail_SupplierWeChat").val(data.Contact.WeChat);
                $(".detail_SupplierEmail").val(data.Contact.Email);
                $(".detail_SupplierSkype").val(data.Contact.Skype);
                $(".detail_SupplierMobilePhone").val(data.Contact.MobilePhone);
                $(".detail_SupplierMobilePhone1").val(data.Contact.MobilePhone1);
                $(".detail_ShortName").val(data.ShortName);
                $(".detail_SupplierCountry").val(data.Address.Country);
                $(".detail_SupplierState").val(data.Address.State);
                $(".detail_SupplierCity").val(data.Address.City);
            } else {
//             alertMsgBox(_result.msginfo);
               myApp.alert(_(_result.msginfo));
               
            }
        }
    });
}

//获取参数
function getParamer() {
    var requestSupplier = {};
    return requestSupplier;
}
//以下为截取url的方法，a链接跳转加样式
function returnUrl(href){
    var number=href.lastIndexOf("/");
    return href.substring(number+1);
};
function returnFileName(href){
    var number1=href.lastIndexOf("/");
    var number2= href.substring(0,number1).lastIndexOf("/");
    return href.substring(number1,number2+1);
};
//--jq不区分大小写过滤筛选
jQuery.expr[':'].Contains = function (a, i, m) {
    return jQuery(a).text().toUpperCase()
        .indexOf(m[3].toUpperCase()) >= 0;
};
// OVERWRITES old selecor    
jQuery.expr[':'].contains = function (a, i, m) {
    return jQuery(a).text().toUpperCase()
        .indexOf(m[3].toUpperCase()) >= 0;
};
//屏蔽开关
function Filter(me, type, state) {
    //type = type == 1 ? "stocks" : type == 3 ? "inlays" : "parcels";    // 1暂定裸钻，2 统包 3成品
    if(type==1){
        type="stocks";
    }else if(type==2){
        type="parcels";
    }else if(type==3){
        type="inlays"
    }else if(type==4){
        type="gems"
    }else if(type==5){
        type="emeralds"
    }else if(type==6){
        type=="golds"
    }else if(type==7){
        type="inlay_settings";
    }
    $.ajax({
        url: "/Team/SetSupplier",//提交地址
        type: "POST",//提交方式
        data: "{'SupplierCode':'" + me.getAttribute("value") + "','SupplierShortName':'" + me.getAttribute("data-shortname") + "','SupplierType':'" + sType + "','supplierName':'" + me.getAttribute("lang") + "','category':'" + type + "','state':'" + (state == 1 ? true : false) + "'}", //{"supplierCode":"YDT","category":"stocks","state":false}
        contentType: "application/json; charset=utf-8",
        success: function (result) {
        	myApp.hideIndicator();//隐藏加载中
            var _result = eval('(' + result + ')');//eval()解析单个json对象
            if (_result.result == true) {
            	myApp.alert(_("屏蔽成功"));
                //alertMsgBox("屏蔽成功，可到【屏蔽】-【黑名单】查看。");
                LoadSupplier();//重新加载数据
            } else {
            	myApp.alert(_("屏蔽失败"));
            }

        }
    });

}

//操作里面开/关
//function IsOpenWhite(state) {
//  //CustomerID值组装
//  var suppliercodelistCb = $("#product_table tbody input[type='checkbox']:checked"); //选中
//  if (suppliercodelistCb.length == 0) {
////      alertMsgBox(_("未选中任何供应商"));
//		myApp.alert(_("未选中任何供应商"));
//      return;
//  }
//  var tipStr = _("开启");
//  if (state == 0) {
//      tipStr = _("关闭");
//      suppliercodelistCb = $("#product_table tbody input[type='checkbox']").not("input:checked");//unchecked的
//  }
//  var whiteListObj = {};
//  whiteListObj.whitelist = {};
//
//  var temp = []; //全部关闭默认状态
//  var fullName = [];
//  for (var i = 0; i < suppliercodelistCb.length; i++) {
//      temp.push(suppliercodelistCb[i].lang);
//      fullName.push(suppliercodelistCb[i].lang);
//  }
//  switch (sType) {
//      case "1":
//          whiteListObj.whitelist.stocks = temp; break;
//      case "2":
//          whiteListObj.whitelist.inlays = temp; break;
//      case "3":
//          whiteListObj.whitelist.parcels = temp; break;
//  }
//  //全称
//	var dblChoseAlert = simpleAlert({
//		"content":_("批量") + tipStr + _("此操作会") + tipStr + _("对应库存显示,确认？"),
//		"buttons":{
//			"确定":function () {					
//				dblChoseAlert.close();//关闭弹框
//				setTimeout(function(){//需要延迟才可以，不然方法里面的弹出框不显示
//					$.ajax({
//			            url: "/Team/SetSuppliers",//提交地址
//			            type: "POST",//提交方式
//			            data: JSON.stringify(whiteListObj), //{"supplierCode":"YDT","category":"stocks","state":false}
//			            contentType: "application/json; charset=utf-8",
//			            success: function (result) {
//			                var _result = eval('(' + result + ')');//eval()解析单个json对象
//							console.log(_result)
//			                if (_result.msgcode == true) {
//			                    alertMsgBox(_("批量") + tipStr + _("成功"));
//			                    LoadSupplier();
//			                } else {
//			                    alertMsgBox(_("批量") + tipStr + _("失败") + _(_result.msginfo));
//			                }
//			                LoadSupplier();
//			            }
//			        });					
//				},300);	
//			},
//			"取消":function () {				
//				dblChoseAlert.close();
//			}
//		}
//	});
//}


////排序相关
//        //tableid  第几行是标签行(头部)，从第几列开始排序，从第几行开始排序，第几行结束排序(999表示最后) 升序标签样式，降序标签样式  选中列样式
//        //注意标签行的class应该是一致的
//var tableSort = function () {
//  this.initialize.apply(this, arguments);
//}
////var ex1 = new tableSort('product_table', 1, 1, 2, 999, 'sort_up', 'sort_down', 'hov');
////tableSort. 初始化
//tableSort.prototype = {
//  initialize: function (tableId, clickRow,startcloum, startRow, endRow, classUp, classDown, selectClass) {
//      this.Table = document.getElementById(tableId);
//      this.rows = this.Table.rows;//所有行
//      this.Tags = this.rows[clickRow - 1].cells;//标签td
//      this.up = classUp;
//      this.down = classDown;
//      this.startcloum = startcloum;
//      this.startRow = startRow;
//      this.selectClass = selectClass;
//      this.endRow = (endRow == 999 ? this.rows.length : endRow);
//      this.T2Arr = this._td2Array();//所有受影响的td的二维数组
//      this.setShow();
//  },
//  //设置标签切换
//  setShow: function () {
//      var defaultClass = this.Tags[0].className;
//      for (var Tag, i = this.startcloum; Tag = this.Tags[i]; i++) { //设置列点击监听
//          Tag.index = i;
//          addEventListener(Tag, 'click', Bind(Tag, statu));
//      }
//      var _this = this;
//      var turn = 0;
//      function statu() {
//          for (var i = 0; i < _this.Tags.length; i++) {
//              _this.Tags[i].className = defaultClass;
//          }
//          if (turn == 0) {
//              addClass(this, _this.down)
//              _this.startArray(0, this.index);
//              turn = 1;
//          } else {
//              addClass(this, _this.up)
//              _this.startArray(1, this.index);
//              turn = 0;
//          }
//      }
//  },
//  //设置选中列样式
//  colClassSet: function (num, cla) {
//      //得到关联到的td
//      for (var i = (this.startRow - 1) ; i < (this.endRow) ; i++) {
//          for (var n = 0; n < this.rows[i].cells.length; n++) {
//              removeClass(this.rows[i].cells[n], cla);
//          }
//          addClass(this.rows[i].cells[num], cla);
//      }
//  },
//  //开始排序  num 根据第几列排序  aord 逆序还是顺序
//  startArray: function (aord, num) {
//      var afterSort = this.sortMethod(this.T2Arr, aord, num);//排序后的二维数组传到排序方法中去
//      this.array2Td(num, afterSort);//输出
//      
//  },
//  //将受影响的行和列转换成二维数组
//  _td2Array: function () {
//      var arr = [];
//      for (var i = (this.startRow - 1), l = 0; i < (this.endRow) ; i++, l++) {
//          arr[l] = [];
//          for (var n = 0; n < this.rows[i].cells.length; n++) {
//              arr[l].push(this.rows[i].cells[n].innerHTML);
//          }
//      }
//      return arr;
//  },
//  //根据排序后的二维数组来输出相应的行和列的 innerHTML 
//  array2Td: function (num, arr) {
//      this.colClassSet(num, this.selectClass);
//      for (var i = (this.startRow - 1), l = 0; i < (this.endRow) ; i++, l++) {
//          for (var n = 0; n < this.Tags.length; n++) {
//              this.rows[i].cells[n].innerHTML = arr[l][n];
//          }
//      }
//  },
//  //传进来一个二维数组，根据二维数组的子项中的w项排序，再返回排序后的二维数组
//  sortMethod: function (arr, aord, w) {
//      //var effectCol = this.getColByNum(whichCol);
//      arr.sort(function (a, b) {
//          x = killHTML(a[w]);
//          y = killHTML(b[w]);
//          x = x.replace(/,/g, '');
//          y = y.replace(/,/g, '');
//          switch (isNaN(x)) {
//              case false:
//                  return Number(x) - Number(y);
//                  break;
//              case true:
//                  return x.localeCompare(y);
//                  break;
//          }
//      });
//      arr = aord == 0 ? arr : arr.reverse();
//      return arr;
//  }
//}
///*-------------监听事件----------------------*/
//function addEventListener(o, type, fn) {
//  if (o.attachEvent) { o.attachEvent('on' + type, fn) }
//  else if (o.addEventListener) { o.addEventListener(type, fn, false) }
//  else { o['on' + type] = fn; }
//}
////是否包含样式
//function hasClass(element, className) {
//  var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
//  return element.className.match(reg);
//}
////用来设置添加样式
//function addClass(element, className) {
//  if (!this.hasClass(element, className)) {
//      element.className += " " + className;
//  }
//}
////用来设置删除样式
//function removeClass(element, className) {
//  if (hasClass(element, className)) {
//      var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
//      element.className = element.className.replace(reg, ' ');
//  }
//}
////绑定监听
//var Bind = function (object, fun) {
//  return function () {
//      return fun.apply(object, arguments);
//  }
//}
////去掉所有的html标记
//function killHTML(str) {
//  return str.replace(/<[^>]+>/g, "");
//}
////排序相关end
